package com.nulstudio.cloud.common.entity;

import com.nulstudio.cloud.common.exception.NulException;
import com.nulstudio.cloud.common.exception.NulExceptionConstants;
import com.nulstudio.cloud.common.util.FieldValidityAssertion;
import org.springframework.lang.Nullable;

public final class NulSupplier {
    private int id;

    private String name;

    private String contact;

    private String phone;

    private String email;

    private String address;

    public NulSupplier(int id, String name, String contact, String phone, String email, String address) {
        this.id = id;
        this.name = name;
        this.contact = contact;
        this.phone = phone;
        this.email = email;
        this.address = address;
    }

    public NulSupplier(String name, String contact, String phone, String email, String address) {
        this.id = 0;
        this.name = name;
        this.contact = contact;
        this.phone = phone;
        this.email = email;
        this.address = address;
    }

    public static void assertValidity(@Nullable NulSupplier supplier) throws NulException {
        if (supplier == null)
            throw new NulException(NulExceptionConstants.SUPPLIER_NOT_EXIST);
        FieldValidityAssertion.assertEmail(supplier.getEmail());
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
